import 'package:sainbainu/common/apis/user_api.dart';
import 'package:sainbainu/common/apis/version_api.dart';
import 'package:sainbainu/common/enums/platform_type.dart';
import 'package:sainbainu/common/models/request/pager_request.dart';
import 'package:sainbainu/common/models/response/version_list_response.dart';

import 'package:sainbainu/common/models/response/version_update_response.dart';

class VersionRepository {
  final VersionApi _versionApi;

  VersionRepository(this._versionApi);

  /// 新版本
  Future<VersionUpdateResponse> newVersion(PlatformType platformType) async {
    var res = await _versionApi.newVersion({
      'platformType': platformType.value,
    });
    return VersionUpdateResponse.fromJson(res['data']);
  }

  /// 版本列表
  Future<VersionListResponse> versionList(
    PagerRequest pagerRequest,
    PlatformType platformType,
  ) async {
    var data = pagerRequest.toJson();
    data['platformType'] = platformType.value;
    var res = await _versionApi.versionList(data);
    return VersionListResponse.fromJson(res);
  }
}
